import lejos.nxt.Button;
import lejos.nxt.ButtonListener;
import lejos.nxt.SensorPort;
import ch.aplu.nxt.*;
import lejos.nxt.LCD;

public class TestExpKit {
	private final int out = 1;
	private boolean exit = false;
	private int[] dout;

	public TestExpKit() {
		NxtRobot robot = new NxtRobot();
		SuperProSensor sps = new SuperProSensor(ch.aplu.nxt.SensorPort.S4);
		robot.addPart(sps);
		dout = new int[8];
		int[] ain = new int[4];
		int[] ioControl = { out, out, out, out, out, out, out, out };
		sps.setDIO(ioControl);
		
		while(Button.ESCAPE.isUp())  {
			sps.readAnalog(ain);
			LCD.clear();
			LCD.drawInt(ain[0], 7, 4);
			if (ain[0] < 512) {
				dout[0] = 0;
				dout[1] = 1;
			}
			else {
				dout[0] = 1;
				dout[1] = 0;
			}
			sps.write(dout);
			Tools.delay(50);
		}
		
		for(int i = 0; i < 8; i++) {
			dout[i] = 0;
		}
		sps.write(dout);
	}

	public static void main(String[] args) {
		new TestExpKit();
	}
}
